<template>
  <div class="tableListPage">
    <!-- 搜索区域 -->
    <div class="tableListSearch">
      <pending-search @clickbtn="handleSearch"></pending-search>
    </div>
    <!-- 列表区域 -->
    <div class="tableListMain commonTableSty" style="height:calc(100% - 90px)">
      <pending-table-list ref="pendingReviewTableComp" @operateRow="handleRowOperation"></pending-table-list>
    </div>
  </div>
</template>
<script>
import PendingSearch from './components/PendingSearch.vue'
import PendingTableList from './components/PendingTableList.vue'
import {mapState} from "vuex";

export default {
  components: {
    PendingSearch,
    PendingTableList
  },
  computed: {
    ...mapState({
      instantUpdateTime: (state) => state.app.instantUpdateTime
    })
  },
  data () {
    return {}
  },
  created () {},
  watch:{
    instantUpdateTime: {
      handler(val) {
        if(val) {
          this.$nextTick(() => {
            this.$refs.pendingReviewTableComp.refreshData(false);
          })
        }
      },
      immediate: true
    }
  },
  mounted () {},
  methods: {
    // 查询表格数据
    handleSearch () {
      this.$refs.pendingReviewTableComp.refreshData(true)
    },
    // 表格传递上来的事件
    handleRowOperation (data) {
      // 按照type分发事件
      this[data[0]](data[1])
    },
    // 通过审核
    pass (data) {
      this.$router.push({ path: '/todo/applicationContent',
        query: {
          p: data.taskId,
          id: data.instanceId,
          swcode: data.businessCode,
          key: data.businessKey,
          // 是否跳到查看审核流程模块
          toReview:1,
          // 是从我的申请跳转过去还是从我的审核跳转过去，会影响底部的操作信息栏加载
          aorr: 'r',
          status: 10,
          midParam:10,
          toAction: true
        }
      })
    },
    // 驳回审核
    reject (data) {
      this.$router.push({ path: '/todo/applicationContent',
        query: {
          p: data.taskId,
          id: data.instanceId,
          swcode: data.businessCode,
          key: data.businessKey,
          // 是否跳到查看审核流程模块
          toReview:1,
          // 是从我的申请跳转过去还是从我的审核跳转过去，会影响底部的操作信息栏加载
          aorr: 'r',
          status: 10,
          midParam:10,
          toAction: true
        }
      })
    },
    // 跳转审批流程
    auditProcess (data) {
      this.$router.push({ path: '/todo/applicationContent',
        query: {
          id: data.instanceId,
          p: data.taskId,
          swcode: data.businessCode,
          key: data.businessKey,
          // 是否跳到查看审核流程模块
          toReview:1,
          // 是从我的申请跳转过去还是从我的审核跳转过去，会影响底部的操作信息栏加载
          aorr: 'r',
          status: 10,
          midParam:10,
        }
      })
    }
  }
}
</script>
<style lang="less" scoped>
.tableListPage {
  height: 100%;
  overflow: hidden;
  .tableListAction {
    margin-top: 16px;
    button {
      margin-right: 16px;
      &:nth-last-child(1) {
        margin-right: 0;
      }
    }
  }
  .tableListMain {
    margin-top: 16px;
  }
}
</style>
